package NumArray;

public class NumArray {
    int []sums;
    public NumArray(int[] nums) {
        int n = nums.length;
        sums = new int[n];
        sums[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            sums[i] = sums[i-1] + nums[i];
        }
    }

    public int sumRange(int left, int right) {
        return sums[right] - sums[left];
    }
}
